package com.djnt.catering.sales_promotion;

import android.app.Activity;
import android.content.ContentUris;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.djnt.catering.R;
import com.djnt.catering.database.HotNews;
import com.djnt.catering.database.ViewHotNewsUsers;

public class SalesPromotionManager extends Activity implements
		OnItemClickListener {

	private static final String TAG = "UserCompanyFavorActivity";
	private SalesPromotionListAdapter mAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.user_company_favor);

		Cursor c = this.getContentResolver().query(HotNews.CONTENT_URI, null,
				null, null, HotNews.DEFAULT_SORT_ORDER);
		ListView v = (ListView) this.findViewById(R.id.list1);
		mAdapter = new SalesPromotionListAdapter(this,
				R.layout.sales_promotion_list_item, c);
		v.setAdapter(mAdapter);
		v.setOnItemClickListener(this);
	}

	public void onNewFavor(View view) {
		Intent i = new Intent(this, UserCompanyFavorNew.class);
		startActivity(i);
	}

	public void onSearchFavor(View view) {
		Intent i = new Intent(this, UserCompanyFavorSearch.class);
		startActivity(i);
	}

	public void onSortFavor(View view) {
		Intent i = new Intent(this, UserCompanyFavorSort.class);
		startActivity(i);
	}

	public void onSync(View view) {
		Intent i = new Intent(this, UserCompanyFavorSync.class);
		startActivity(i);
	}

	public void onSettings(View view) {
		Intent i = new Intent(this, UserCompanyFavorSettings.class);
		startActivity(i);
	}

	@Override
	public void onItemClick(AdapterView<?> adapter, View arg1, int position,
			long arg3) {
		// TODO Auto-generated method stub
		final long id = mAdapter.getItemId(position);
		Uri uri = ContentUris.withAppendedId(HotNews.CONTENT_URI, id);
		Intent i = new Intent(this, UserCompanyFavorEdit.class);
		i.setData(uri);
		startActivity(i);
	}
}
